function showBizOrgApp() {
    $('#_bizOrgAppTD').addClass('active');
    $('#_bizOrgAppFuncTD').removeClass('active');
    $('#_bizOrgAppDiv').attr("hidden",false);
    $('#_bizOrgAppFuncDiv').attr("hidden",true);
}

function showBizOrgAppFunc() {
    $('#_bizOrgAppFuncTD').addClass('active');
    $('#_bizOrgAppTD').removeClass('active');
    $('#_bizOrgAppDiv').attr("hidden",true);
    $('#_bizOrgAppFuncDiv').attr("hidden",false);
}

function openQRCode() {
    console.log(appidstr);
    $.ajax({
        type: 'post',
        url: basePath + 'checkOrgApp/updateQRCode',
        dataType: 'json',
        contentType: "application/json",
        data: JSON.stringify({appid:appidstr,orgCode:orgCodeStr}),
        success : function (data) {
            if(data.result){
                // console.log(data.content)
                // //移除当前已生成数据
                $("#_validNum").text(data.content.validNum);
                $("#scanCode").attr("src",data.content.qrUrl);
                $("#publishApp").modal(true);
            }else{
                toastr.error(data.message);
            }
        },
        error: function (request) {
            toastr.error(common_system_error);
        }
    });
}


function doPublish() {
    $.ajax({
        type: 'post',
        url: basePath + 'checkOrgApp/publishOrg',
        dataType: 'json',
        contentType: "application/json",
        beforeSend:function () {
            showLoading();
        },
        complete:function(){
            hideLoading();
        },
        data: JSON.stringify({id:idStr,appid:appidstr,batchId:batchIdStr}),
        success : function (data) {
            if(data.result){
                toastr.success(data.message);
               $("#publishApp").modal(true);
                // window.location.href = basePath + 'checkOrgApp/pendingCheckOrgPage';
                doClose();
            }else{
                toastr.error(data.message);
            }
        },
        error: function (request) {
            toastr.error(common_system_error);
        }
    });
}

function doUnPublish() {
    $("#error_textarea").val("");
    $("#unPublishAppWin").modal(true);
}

function doUnPublishApp() {
    if($.trim($("#error_textarea").val()) == ''){
        toastr.error("请输入不通过的原因！");
        return;
    }
    $.ajax({
        type: 'post',
        url: basePath + 'checkOrgApp/unPublishOrg',
        dataType: 'json',
        contentType: "application/json",
        beforeSend:function () {
            showLoading();
        },
        complete:function(){
            hideLoading();
        },
        data: JSON.stringify({id:idStr,appid:appidstr,orgCode:orgCodeStr,appCategory:"org",batchId:batchIdStr,remark: $("#error_textarea").val()}),
        success : function (data) {
            if(data.result){
                toastr.success(data.message);
                $("#unPublishAppWin").modal('hide');
                $("#publishApp").modal('hide');
                // window.location.href = basePath + 'checkOrgApp/pendingCheckOrgPage';
                doClose();
            }else{
                toastr.error(data.message);
            }
        },
        error: function (request) {
            toastr.error(common_system_error);
        }
    });
}
function doClose() {
    if(typeStr == 'check'){
        var str = '&orgName=' + searchInfo.orgName + '&isvPid=' + searchInfo.isvPid + '&isvName=' + searchInfo.isvName
            + '&isQueryExist=' + searchInfo.isQueryExist + '&isCheckExist=' + searchInfo.isCheckExist
            + '&checkType=' + searchInfo.checkType + '&timeInterval=' + searchInfo.timeInterval + '&endTimeStr=' + searchInfo.endTimeStr + '&result=' + searchInfo.result
            + '&bizCode=' + searchInfo.bizCode + '&pageNo=' + searchInfo.pageNo + '&pageSize=' + searchInfo.pageSize;
        window.location.href = basePath + 'checkOrgApp/checkedOrgAppPage?t=' + new Date().getTime() + str;
    }else{
        var str = '&orgName=' + searchInfo.orgName + '&isvPid=' + searchInfo.isvPid + '&isvName=' + searchInfo.isvName
            + '&isQueryExist=' + searchInfo.isQueryExist + '&isCheckExist=' + searchInfo.isCheckExist
            + '&checkType=' + searchInfo.checkType + '&timeInterval=' + searchInfo.timeInterval + '&endTimeStr=' + searchInfo.endTimeStr
            + '&bizCode=' + searchInfo.bizCode + '&pageNo=' + searchInfo.pageNo + '&pageSize=' + searchInfo.pageSize;
        window.location.href = basePath + 'checkOrgApp/pendingCheckOrgPage?t=' + new Date().getTime() + str;
    }
}


function toPass() {
    swal({
        title: '提示',
        text: "确定要通过这个机构服务吗？",
        showCancelButton:"true",
        showConfirmButton:"true",
        confirmButtonText:"确定",
        cancelButtonText:"取消",
        animation:"slide-from-top"
    }, function() {
        doPublish();
    });
}

